<?php
/**
 * 话说分类管理
 * Created by PhpStorm.
 * User: zd
 * Date: 2018/12/8
 * Time: 14:46
 */

namespace app\api\model;


class WorkWordClassify extends BaseModel
{
    protected $autoWriteTimestamp = true;
    protected $hidden=['t_id','sort','create_time','update_time','delete_time'];

    /**
     * 与work_word为1对多关系
     * @return \think\model\relation\HasMany
     */
    protected function  word(){
        return $this->hasMany("WorkWord",'c_id','id');
    }
    /**
     * 话术添加
     * @param $data
     * @return false|int
     */
        public static function addWordClassify($data){
            return (new WorkWordClassify())->save($data);
        }
    /**
     * 删除分类
     * @param $id
     * @return int
     */
        public static function deleteClassify($id){
            return self::destroy($id);
        }
    /**
     * 更新分类
     * @param $info
     * @return false|int
     */
        public static function updateClassify($info){
            $where['id']=$info['id'];
            return (new WorkWordClassify())->save($info,$where);
        }
    /**
     * 获取话术分类
     * @param $t_id
     * @return false|\PDOStatement|string|\think\Collection
     */
        public static function getClassify($t_id){
            return self::where('t_id','=',$t_id)->select();
        }
    /**
     * 根据用户id获取分类
     * @param $uid
     * @return false|\PDOStatement|string|\think\Collection
     */
        public static function getCalssifyByUid($uid){
            $user = WorkUser::getUserByWuID($uid);
            $t_id = $user->t_id;
            return self::where('t_id','=',$t_id)->select();
        }
}